<template>
  <div class="page">
    <div class="ad">
      <span class="text1 red">双线质量管控体</span>
      <span class="text2">力求每件产品<span class="dian">、</span>每个细节都尽善尽美</span>
      <span class="text4">够专业</span>
      <span class="text3">才放心</span>
      <div class="left-top">
      </div>
      <div class="right-buttom">
      </div>
    </div>
    <div class="lodinBox">
      <div class="order1">ORDER聚造</div>
      <div class="order2">ORDER聚造</div>
      <div class="welcome">
        <span>欢迎使用</span>
      </div>
      <div class="title">
        <span ref="dlxtTest">系统登录</span>
      </div>
      <el-form :model="ruleForm" :hide-required-asterisk="true" :rules="rules" ref="ruleForm" label-width="60px" class="inputBox">
        <div class="inputDiv">
          <el-form-item label="用户名" prop="userName">
            <el-input autosize v-model="ruleForm.userName">
              <img slot="prefix" class="inputIcon" src="../assets/user.png" />
            </el-input>
          </el-form-item>
        </div>
        <div class="inputDiv">
          <el-form-item label="密  码" prop="passWord">
            <el-input autosize type="password" v-model="ruleForm.passWord">
              <img slot="prefix" class="inputIcon" src="../assets/key.png" />
            </el-input>
          </el-form-item>
        </div>
      </el-form>
      <div class="button" @click="submitForm">登录</div>
    </div>
    <div class="copy">All Rights Reserved ©2021 版权所有 ｜ 粤ICP备18069755号</div>
  </div>
</template>

<script>

import md5 from 'js-md5'

export default {
  name: 'login',
  components: {
    
  },
  data(){
    return {
      ruleForm:{
        userName:'',
        passWord:''
      },
      rules:{
        userName:[
          { required: true, message: '请输入用户名', trigger: 'blur' }
        ],
        passWord:[
          { required: true, message: '请输入密码', trigger: 'blur' }
        ]
      }
    }
  },
  methods:{
    submitForm(){
      console.log('this.$refs',this.$refs)
      this.$refs.ruleForm.validate((valid) => {
        console.log(valid)
        if (valid) {
          this.$http({
            url:'/login',
            method:'POST',
            data:{
              userName:this.ruleForm.userName,
              passWord:md5(this.ruleForm.passWord),
              platform:'Web'
            }
          }).then(res => {
            if(!res.errorMsg){
              localStorage.setItem('token',res.token)
              localStorage.setItem('user',JSON.stringify(res))
              this.$router.push('/index')
            }
          })
        }
      });
    }
  },
  created(){

  },
  mounted(){
    
  }
}
</script>

<style scoped>
  .page{
    width: 100%;
    height: 100%;
    background: url(../assets/login_bg.png) center center no-repeat;
    background-size: 100% 100%;
  }
  .order1{
    opacity: 0.3;
    font-size: 36px;
    font-weight: 700;
    color: #d7e8fa;
    position: absolute;
    left: 260px;
    top:-50px;
  }
  .order2{
    font-size: 20px;
    font-weight: 700;
    color: #409eff;
    position: absolute;
    left: 255px;
    top:-24px;
  }
  .lodinBox {
    width: 480px;
    height: 480px;
    opacity: 0.9;
    background-color: #efeff0;
    border-radius: 20px;
    position: fixed;
    right:160px;
    top:50%;
    transform: translate(0,-55%);
  }
  .welcome {
    width: 56px;
    height: 12px;
    font-size: 14px;
    text-align: center;
    color: #96a3b0;
    font-family: Microsoft YaHei UI, Microsoft YaHei UI-Regular;
    margin-top: 38px;
    margin-left: 40px;
  }
  .title {
    width: 144px;
    height: 34px;
    font-size: 36px;
    text-align: center;
    color: #4e4e4e;
    font-weight: 700;
    margin-top: 18px;
    margin-left: 40px;
  }
  .inputBox {
    margin-top: 55px;
    margin-left: 40px;
  }

  .inputDiv{
    margin-right: 36px;
    height: 50px;
    margin-top: 11px;
  }

  .button {
    width: 404px;
    height: 51px;
    background-color: #409eff;
    font-size: 20px;
    line-height: 51px;
    text-align: center;
    margin: 0 auto;
    border-radius: 26px;
    color: #f4f4f5;
    margin-top: 63px;
  }
  .button:hover {
    opacity: 0.8;
    cursor: pointer;
  }
  .active {
    border: 2px solid #ff0000;
  }
  .inputIcon{
    width: 18px;
    height: 18px;
    margin-top: 12px;
    margin-left: 4px;
  }

  .ad{
    width: 315px;
    height:407px ;
    position: fixed;
    left: 160px;
    top:50%;
    transform: translate(0,-50%);
  }
  .left-top {
    width: 147px;
    height: 202px;
    background-color: #e1f2f9;
    opacity: 0.3;
    position: relative;
  }

  .right-buttom {
    width: 168px;
    height: 205px;
    background-color: #e1f2f9;
    margin-left: 90px;
    position: relative;
    opacity: 0.3;
  }
  .text1 {
    display: block;
    width: 24px;
    color: #fefefe;
    font-size: 24px;
    font-weight: 700;
    line-height: 1em;
    left: 61px;
    top: 15px;
    position: absolute;
  }
  .text2 {
    display: block;
    width: 20px;
    font-size: 20px;
    line-height: 1em;
    color: #fff;
    font-weight: 700;
    position: absolute;
    left: 113px;
    top: 15px;
  }
  .text3 {
    display: block;
    width: 36px;
    font-size: 36px;
    color: #6bb9da;
    line-height: 1em;
    font-weight: 700;
    position: absolute;
    bottom: 82px;
    left: 164px;
  }
  .text4 {
    display: block;
    width: 36px;
    font-size: 36px;
    line-height: 1em;
    color: #6bb9da;
    font-weight: 700;
    position: absolute;
    left: 164px;
    top:79px;
  }

  .dian {
    display: block;
    text-align: right;
    margin: -3px 0 6px 12px;
  }
  .copy {
    font-size: 14px;
    font-weight: 700;
    text-align: center;
    color: #565656;
    position: fixed;
    left: 0;
    right: 0;
    bottom: 24px;
  }
  @media screen and ( max-width: 1440px ) {
    .lodinBox{
      transform: translate(50px,-55%) scale(0.8);
    }
    .ad{
      transform: translate(-100px,-50%) scale(0.8);
    }
    .copy{
      transform: translate(0,10px) scale(0.8);
    }
  }
</style>